package com.virus.server.http;

import javax.servlet.ServletContext;
import java.util.HashMap;
import java.util.Map;

public class ContextSession extends BaseSession {

    private long lastAccessedTime;

    private String id;

    private ServletContext servletContext;

    private Integer maxInactiveInterval;

    private Map<String, Object> attribute;

    public ContextSession(String id, ServletContext servletContext) {
        this.id = id;
        this.servletContext = servletContext;
        this.attribute = new HashMap<>();
    }

    @Override
    public long getLastAccessedTime() {
        return lastAccessedTime;
    }

    public void setLastAccessedTime(long lastAccessedTime) {
        this.lastAccessedTime = lastAccessedTime;
    }

    @Override
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public ServletContext getServletContext() {
        return servletContext;
    }

    public void setServletContext(ServletContext servletContext) {
        this.servletContext = servletContext;
    }

    @Override
    public int getMaxInactiveInterval() {
        return maxInactiveInterval;
    }

    @Override
    public void setMaxInactiveInterval(int maxInactiveInterval) {
        this.maxInactiveInterval = maxInactiveInterval;
    }

    @Override
    public Object getAttribute(String s) {
        return attribute.get(s);
    }

    @Override
    public void setAttribute(String s, Object o) {
        this.attribute.put(s, o);
    }
}